function score = getScore(r, center, coords)
%GETSCORE returns score points for 2D coordinates COORDS using radius R and
%   central point CENTER of the dart board.

% Project:  Dart detection [Bildfolgen LU]@CVL/TUWIEN
% Author:   Thomas Rittler
% Date:     05/2011


r = r*(1.7/2.25); %(3/4);

[theta rho] = cart2pol(coords(1)-center(1), center(2)-coords(2));
theta = radtodeg(theta)+9;
if theta<0;
    theta = theta+360;
end
% th = theta;
theta = ceil(theta/18)-.1; %-.165
beye = r*(6.35/1.7)/100;
bull = r*(15.9/1.7)/100;
dtsz = r*(8/1.7)/100; % double/triple field size
% triple boundaries
tup = r*(107/1.7)/100;
tlow = tup-dtsz;
% double boundary
dlow = r-dtsz;

if rho <= beye
    score = '50';
    theta = 0;
elseif rho > beye && rho <= bull
    score = '25';
    theta = 0;
elseif rho >= tlow && rho <= tup
    special = 't';
elseif rho >= dlow  && rho <= r
    special = 'd';
elseif rho > r
    score = 'out';
    theta = 0;
else
    special = 's';
end


switch theta
    case 1
        score = '6';
    case 2
        score = '13';
    case 3
        score = '4';
    case 4
        score = '18';
    case 5
        score = '1';
    case 6
        score = '20';
    case 7
        score = '5';
    case 8
        score = '12';
    case 9
        score = '9';
    case 10
        score = '14';
    case 11
        score = '11';
    case 12
        score = '8';
    case 13
        score = '16';
    case 14
        score = '7';
    case 15
        score = '19';
    case 16
        score = '3';
    case 17
        score = '17';
    case 18
        score = '2';
    case 19
        score = '15';
    case 20
        score = '10';
    otherwise
        special = '';
end
score = sprintf('%s%s', special, score);
%score = sprintf('%s%s(r:%6.2f, rh:%6.2f, th:%6.2f)', special, score, r,  rho, th);

end

